/**
 @Author Zhenglinbin
 @Date 2021/3/24
 **/
import {Props} from "@/components/typing";

export const buildType = (configList: Props[]) => {
    if(!configList || configList.length < 1) return configList
    const result: Props[] = []

    configList.forEach(item => {
        item.childrenType = 1
        const config: Props = item
        const indicatorList: Props[] = []
        const radioList: Props[] = []

        if(item.indicatorList && item.indicatorList.length > 0) {
            item.indicatorList.forEach((indicator: Props) => {
                if(indicator.type === 3) {
                    radioList.push(indicator)
                    config.childrenType = 2
                } else {
                    indicatorList.push(indicator)
                }
            })
        }
        config.indicatorList = indicatorList
        config.radioList = radioList
        result.push(config)
    })
    return result
}
